/*
 * Copyright 2008 Wink Saville
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.saville.msgcomp;

public interface IMcMgr {

    /*
     * Get the name of the instance, used for debugging
     */
    public String getName();

    /*
     * Register the mc
     * 
     * @return the McId
     */
    public McId register(String name, IMc mc);

    /*
     * Register using an McId
     * 
     * @return the McId
     */
    public McId registerMcId(McId mcId);

    /*
     * Lookup the named Mc.
     * 
     * @return unique id for this Mc.
     */
    public int lookup(String name);

    /*
     * Lookup the named Mc.
     * 
     * @return McId for this Mc.
     */
    public McId lookupMcId(String name);
    
    /*
     * A set of SessionIds
     */
    public class SessionIdSet {
        public long firstSessionId;
        public long numSessionIds;
    }
    
    /*
     * Get a set of SessionIds
     * 
     * @return SessionIdSet
     */
    public SessionIdSet getSessionIdSet();
    
    /*
     * Get a session id
     */
    public long getSessionId();

    /*
     * Send the msg to the msg.dstId
     */
    public void sendMsg(Msg msg);

    /*
     * Sends a duplicate of msg reversing dstId/dstSubId and srcId/srcSubId and
     * sets dupMsg.status = status.
     */
    public void sendReplyMsg(Msg msg, int status);

    /*
     * Get a new msg from the pool.
     */
    public Msg getMsg();

    /*
     * Get a new msg setting some fields
     */
    public Msg getMsg(int srcId, int dstId, int guid, int cmd);

    /*
     * return the message to the pool.
     */
    public void retMsg(Msg msg);

    /*
     * duplicate the message
     * 
     * @return Msg (currently does not duplicate the msg.obj just references the
     * existing)
     */
    public Msg dupMsg(Msg msg);

    /**
     * Duplidate the msg reversing dstId/dstSubId and srcId/srcSubId and setting
     * msg.status = status
     * 
     * @return msg
     */
    public Msg getReplyMsg(Msg msg, int status);

}
